package com.youlai.system.controller;


import com.youlai.system.common.result.Result;
import com.youlai.system.model.form.AttendanceLeaveSettingForm;
import com.youlai.system.service.IAttendanceLeaveSettingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 只茂瑞
 * @since 2024-06-23
 */
@RestController
@RequestMapping("/api/v1/attendance-leave-setting")
@Tag(name = "16.考勤管理请假设置接口")
@RequiredArgsConstructor
public class AttendanceLeaveSettingController {

    private final IAttendanceLeaveSettingService attendanceLeaveSettingService;

    @Operation(summary = "根据部门id获取请假设计")
    @GetMapping("/{id}/form")
    public Result<List<AttendanceLeaveSettingForm>> getAttendanceLeaveSettingForm(
            @Parameter(description = "部门id") @PathVariable Long id
    ) {
        List<AttendanceLeaveSettingForm> attendanceLeaveSettingForms = attendanceLeaveSettingService.getLeaveSettingForm(id);
        return Result.success(attendanceLeaveSettingForms);
    }

    @Operation(summary = "修改请假设置")
    @PostMapping("/updateLeaveStatus")
    public Result updateLeaveStatus(@RequestBody AttendanceLeaveSettingForm attendanceLeaveSettingForm){
        Integer id = attendanceLeaveSettingService.updateAttendUpdateLeaveStatus(attendanceLeaveSettingForm);
        return Result.success(id);
    }
}
